<?php 
class KatanaUpgrade extends Object
{
	public $Version;
	public function Upgrade()
	{
		global $katana;
		global $db;
		$out = 'Current Version:'.$katana->getVersion();
		if($katana->getVersion() < 1)
		{
			$sql = "RENAME TABLE `hc_menu` TO `hc_sitemap_pages`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "RENAME TABLE `hc_menu_search_index` TO `hc_sitemap_search_index`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "RENAME TABLE `hc_menu_static_html` TO `hc_sitemap_static_html`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_sites` ADD `Version` INT NOT NULL DEFAULT '1224' AFTER `license`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion(1224);
		}
		$v=1225;
		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_shop_orders` ADD `DoubleConfirm` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `confirmed`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_shop_orders` ADD `DoubleConfirmed` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `confirmed`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$katana->setVersion($v);
		}
		$v++;
		if($katana->getVersion() < $v)
		{
			$sql 	= "ALTER TABLE `hc_words` CHANGE `ba` `bs` VARCHAR( 500 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$sql  = "INSERT INTO `hc_words` (`value`, `frontend`, `backend`, `modcom_set`, `katana_core`, `en`, `bs`, `no`) VALUES ";
			$sql .= "('without', '1', '1', '0', '0', 'without', 'bez', 'uten');";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql  = "CREATE TABLE IF NOT EXISTS `hc_am_Import` (
			  `Id` int(11) NOT NULL auto_increment,
			  `UserId` int(11) NOT NULL default '0',
			  `Frequency` tinyint(1) NOT NULL,
			  `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00',
			  `DateLastRun` datetime NOT NULL default '0000-00-00 00:00:00',
			  `URL` varchar(500) NOT NULL,
			  `AutoPublish` tinyint(1) NOT NULL default '0',
			  `active` tinyint(1) NOT NULL default '0',
			  PRIMARY KEY  (`Id`)
			) ENGINE=MyISAM  DEFAULT CHARSET=utf8;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql  = "CREATE TABLE IF NOT EXISTS `hc_am_ImportConverts` (
				  `Id` int(11) NOT NULL auto_increment,
				  `ImportId` int(11) NOT NULL default '0',
				  `ConversionType` tinyint(4) NOT NULL default '0',
				  `RemoteTypeId` int(11) NOT NULL default '0',
				  `RemoteCatId` int(11) NOT NULL default '0',
				  `ToTypeId` int(11) NOT NULL default '0',
				  `ToCatId` int(11) NOT NULL default '0',
				  `FieldFrom` varchar(200) NOT NULL default '',
				  `FieldTo` varchar(200) NOT NULL default '',
				  `ValidType` varchar(100) NOT NULL default '',
				  `ValueFieldReplace` varchar(200) NOT NULL default '',
				  `ValueFrom` varchar(500) NOT NULL default '',
				  `ValueTo` varchar(500) NOT NULL default '',
				  PRIMARY KEY  (`Id`)
				) ENGINE=MyISAM  DEFAULT CHARSET=utf8;";
			
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql 	= "ALTER TABLE `hc_country` ADD `countryOrder` SMALLINT( 6 ) NOT NULL DEFAULT '500' AFTER `numcode`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql 	= "ALTER TABLE `hc_country` ADD `printable_name_bs` VARCHAR( 80 ) NOT NULL DEFAULT '';";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql 	= "ALTER TABLE `hc_country` ADD `printable_name_no` VARCHAR( 80 ) NOT NULL DEFAULT '';";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql 	= "ALTER TABLE `hc_country` ADD `active` TINYINT( 1 ) NOT NULL DEFAULT '1';";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql  = "UPDATE `hc_country` SET `printable_name_ba` = 'Hrvatska', `printable_name_no` = 'Kroatia' WHERE `hc_country`.`iso` = 'HR';";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql  = "INSERT INTO `hc_country` (`iso`, `name`, `printable_name`, `iso3`, `numcode`, `continent`, `countryOrder`, `printable_name_ba`, `printable_name_no`, `active`) VALUES ('CS', 'MONTENEGRO', 'Montenegro', NULL, NULL, 'Europe', '500', 'Crna Gora', 'Montenegro', '1');";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql  = "ALTER TABLE `hc_country` CHANGE `printable_name_ba` `printable_name_bs` VARCHAR( 80 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql  = "ALTER TABLE `hc_product` ADD `Description` MEDIUMTEXT NOT NULL DEFAULT '' AFTER `intro`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql  = "INSERT INTO `hc_words` (`value`, `frontend`, `backend`, `modcom_set`, `katana_core`, `en`, `bs`, `no`) VALUES ";
			$sql .= "('uploaded_image', '1', '1', '0', '0', 'uploaded image', 'dodane slike', 'opplastet bilde'), ";
			$sql .= "('click_to_view_original_version', '1', '1', '0', '6', 'click to view original version', 'kliknite da bi vidjeli orginalnu verziju', 'klikk for original versjon'), ";
			$sql .= "('delete_image', '1', '1', '0', '0', 'delete image', 'izbri&#353;i sliku', 'slett bilde');";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql  = "INSERT INTO `hc_words` (`value`, `frontend`, `backend`, `modcom_set`, `katana_core`, `en`, `bs`, `no`) VALUES ";
			$sql .= "('comfort', '1', '1', '0', '0', 'comfort', 'komfort', 'komfort');";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_am_Import` ADD `HtmlSource` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `DateLastRun`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$out .= self::insertWord('close', 'close', 'zatvori', 'lukk');
			$out .= self::insertWord('product_added_to_cart', 'product added to cart', 'produkt dodan u korpu', 'produktet er lagt i handlekurven');
			$out .= self::insertWord('gasoline', 'gasoline', 'benzin', 'bensin');
			$out .= self::insertWord('continue', 'continue', 'nastavi', 'fortsett');
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql  = "ALTER TABLE `hc_shop_cart_items` ADD `GroupId` INT NOT NULL DEFAULT '0' AFTER `product_cat_id`; ";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_shop_order_items` ADD `CatId` INT NOT NULL DEFAULT '0' AFTER `variation_id`; ";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_shop_order_items` ADD `GroupId` INT NOT NULL DEFAULT '0' AFTER `CatId`; ";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql  = "ALTER TABLE `hc_sites` ADD `MetaTitle` VARCHAR( 250 ) NOT NULL AFTER `language`; ";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_sitemap_pages` ADD `MetaTitle` VARCHAR( 200 ) NOT NULL DEFAULT '' AFTER `layout_id`; ";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "UPDATE `hc_sitemap_pages` SET `MetaTitle` = `title`; ";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$out .= self::insertWord('open', 'open', 'otvori', '&Aring;pne');
			$out .= self::insertWord('open_state', 'open', 'otvoreno', '&Aring;pnet');
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_sitemap_pages` ADD `Description` TEXT NOT NULL DEFAULT '' AFTER `alias`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_sitemap_pages` ADD `Image` VARCHAR( 50 ) NOT NULL DEFAULT '' AFTER `alias`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_sitemap_pages` ADD `ViewsList` INT NOT NULL DEFAULT '0';";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_sitemap_pages` ADD `ViewsDetail` INT NOT NULL DEFAULT '0';";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql  = "CREATE TABLE IF NOT EXISTS `hc_am_ad_files` (
			  `Id` int(11) NOT NULL auto_increment,
			  `AdId` int(11) NOT NULL default '0',
			  `Type` varchar(3) NOT NULL default '',
			  `Title` varchar(100) NOT NULL default '',
			  `Filename` varchar(40) NOT NULL default '',
			  `FileOrder` tinyint(4) NOT NULL default '0',
			  `active` tinyint(1) NOT NULL default '1',
			  PRIMARY KEY  (`Id`),
			  KEY `AdId` (`AdId`)
			) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_am_ads` ADD `ProductLink` VARCHAR( 400 ) NOT NULL DEFAULT '' AFTER `descriptionEn`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$out .= self::insertWord('link', 'link', 'link', 'lenke');
			$out .= self::insertWord('product_link', 'product link', 'produkt link', 'produktlenke');
			
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$out .= self::insertWord('prospect', 'prospect', 'prospekt', 'prospekt');
			$out .= self::insertWord('document', 'document', 'dokument', 'dokument');
			$out .= self::insertWord('documents', 'documents', 'dokumenti', 'dokumenter');
			$out .= self::insertWord('brochure', 'brochure', 'bro&scaron;ura', 'brosjyre');
			$out .= self::insertWord('brochures', 'brochures', 'bro&scaron;ure', 'brosjyrer');
			$out .= self::insertWord('and', 'and', 'i', 'og');
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$out .= self::insertWord('more_info', 'more info', 'informacija', 'mer info');
			$out .= self::insertWord('click_here', 'click here', 'klikni ovdje', 'klikk her');
			$out .= self::insertWord('safe_trading', 'safe trading', 'sigurno trgovanje', 'sikker handel');
			$out .= self::insertWord('read_about', 'read about', 'pro&#269;itajte o', 'les om');
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_product` ADD `SaleStartHour` TINYINT(4) NOT NULL DEFAULT '0' AFTER `product_order`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_product` ADD `SaleEndHour` TINYINT(4) NOT NULL DEFAULT '0' AFTER `SaleStartHour`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_themes` ADD `GridSystem` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `horisontal_pos`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_themes` ADD `Bootstrap` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `GridSystem`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_product` ADD `FrontpageDisplay` TINYINT NOT NULL DEFAULT '0' AFTER `tax_id`";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			
			$sql = "ALTER TABLE `hc_shop_orders` CHANGE `payment_transact` `payment_transact` VARCHAR( 50 ) NOT NULL DEFAULT '0'";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql  = "INSERT INTO `hc_shop_payment` (`id`, `site_id`, `title`, `library`, `description`, `ready_status`, `complete_status`, `type`, `active`) ";
			$sql .= "VALUES (NULL , '0', 'Kortbetaling - Nets', 'nets.php', '', '1', '2', '1', '1'); ";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql  = "INSERT INTO `hc_shop_payment_config` (`id`, `payment_id`, `site_id`, `param`, `value`) ";
			$sql .= "VALUES (NULL , '6', '0', 'merchantId', '12000062');";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql  = "INSERT INTO `hc_shop_payment_config` (`id`, `payment_id`, `site_id`, `param`, `value`) ";
			$sql .= "VALUES (NULL , '6', '0', 'token', 'yG/6K+8t');";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql  = "INSERT INTO `hc_shop_payment_config` (`id`, `payment_id`, `site_id`, `param`, `value`) ";
			$sql .= "VALUES (NULL , '6', '0', 'currencyCode', 'NOK');";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql  = "INSERT INTO `hc_shop_payment_config` (`id`, `payment_id`, `site_id`, `param`, `value`) ";
			$sql .= "VALUES (NULL , '6', '0', 'language', 'no_NO');";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql  = "INSERT INTO `hc_shop_payment_config` (`id`, `payment_id`, `site_id`, `param`, `value`) ";
			$sql .= "VALUES (NULL , '6', '0', 'testMode', '1');";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$katana->setVersion($v);
		}
		$v++;
			
		if($katana->getVersion() < $v)
		{
			$out .= self::insertWord('all_status', 'all status', 'svi statusi', 'alle statuser');
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_am_categories` ADD `LinkToTypeId` INT NOT NULL DEFAULT '0' AFTER `typeId`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_am_categories` ADD `LinkToCatId` INT NOT NULL DEFAULT '0' AFTER `LinkToTypeId`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$katana->setVersion($v);
		}
		$v++;
			
		if($katana->getVersion() < $v)
		{
			$out .= self::insertWord('at_request', 'at request', 'pri upitu', 'p&aring foresp&oslash;rsel');
			$katana->setVersion($v);
		}
		$v++;

		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_product_groups` ADD `Description` TEXT NOT NULL DEFAULT '' AFTER `title_import`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			 
			$sql = "ALTER TABLE `hc_product_cats` ADD `Description` TEXT NOT NULL DEFAULT '' AFTER `title_import`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_am_ads` ADD `ProductLink2` VARCHAR( 400 ) NOT NULL DEFAULT '' AFTER `ProductLink`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_am_ads` ADD `ProductLinkTxt` VARCHAR( 100 ) NOT NULL DEFAULT '' AFTER `ProductLink2`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_am_ads` ADD `ProductLinkTxt2` VARCHAR( 100 ) NOT NULL DEFAULT '' AFTER `ProductLinkTxt`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$out .= self::insertWord('link_title', 'link title', 'link tekst', 'lenketekst');
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			
			$out .= self::insertWord('product_links', 'product links', 'produkt linkovi', 'produktlenker');
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_shop_shipping` ADD `FreeShippingDateActiveStart` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `complete_status`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_shop_shipping` ADD `FreeShippingDateActiveEnd` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `FreeShippingDateActiveStart`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_shop_shipping` ADD `Description` VARCHAR( 250 ) NOT NULL DEFAULT '' AFTER `title`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$out .= self::insertWord('production', 'production', 'produkcija', 'produksjon');
			$out .= self::insertWord('production_report', 'production report', 'raport proizvodnje', 'produksjonsrapport');
			$out .= self::insertWord('production_list', 'production list', 'proizvodna lista', 'produksjonsliste');
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_am_Import` ADD `AutoDelete` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `AutoDelete`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_shop_shipping` ADD `RemoteId` INT( 11 ) NOT NULL DEFAULT '0' AFTER `title`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$out .= self::insertWord('choosen_brand', 'choosen brand', 'izabrana marka', 'valgt merke');
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_product_vars` ADD `NowPriceDateEnd` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `now_price`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$out .= self::insertWord('ends', 'ends', 'zavr&scaron;ava', 'slutter');
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$out .= self::insertWord('DateActiveStart', 'publish date', 'datum publiciranja', 'publiseringsdato');
			$out .= self::insertWord('TimeActiveStart', 'publish time', 'vrijeme publiciranja', 'publiseringstid');
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{

			$sql = "ALTER TABLE `hc_themes` ADD `BootstrapURL` VARCHAR( 400 ) NOT NULL DEFAULT '' AFTER `Bootstrap`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_themes` ADD `BootstrapThemeURL` VARCHAR( 400 ) NOT NULL DEFAULT '' AFTER `BootstrapURL`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$katana->setVersion($v);
		}
		$v++;
		if($katana->getVersion() < $v)
		{
			$out .= self::insertWord('CompleteAndSendOrder', 'complete and send your order', 'po&#353;alji narudzbu', 'fullf&oslash;r og send bestilling');
			$out .= self::insertWord('CompleteOrder', 'complete your order', 'zavr&#353;i narudzbu', 'fullf&oslash;r din bestilling');
			$out .= self::insertWord('SendOrder', 'send your order', 'po&#353;alji narudzbu', 'send bestilling');
			$out .= self::insertWord('ReviewAndConfirmYourOrder', 'review and confirm your order', 'pregledaj i po&#353;alji narudzbu', 'se over og bekreft din ordre');
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{

			$sql = "ALTER TABLE `hc_am_ads` ADD `Conversions` INT NOT NULL DEFAULT '0' AFTER `ViewsGallery`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$out .= self::insertWord('Conversions', 'conversions', 'konverzija', 'konverteringer');
			
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{

			$sql = "ALTER TABLE `hc_am_models` ADD `Code` VARCHAR(50) NOT NULL DEFAULT '' AFTER `Title`, ADD INDEX (`Code`);";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_am_brands` ADD `Code` VARCHAR(50) NOT NULL DEFAULT '' AFTER `title`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = 'SELECT Models.* FROM `hc_am_models` AS Models';
			$result = $db->query($sql);
			$data = $db->fetch($sql, 0);
			$out .= '<br />'.$sql;
			
			if(is_array($data))
			{
				foreach($data as $m)
				{
					$m['Code'] = str_replace(' ', '-', strtolower($m['Title']));
					$sql = "UPDATE `hc_am_models` SET `Code` = '".$m['Code']."' WHERE `hc_am_models`.`Id` = ".$m['Id'].";";
					$q = $db->query($sql);
					$out .= '<br />'.$sql;
				}
			}
			
			$sql = 'SELECT Models.* FROM `hc_am_models` AS Models';
			$result = $db->query($sql);
			$data = $db->fetch($sql, 0);
			$out .= '<br />'.$sql;
			
			if(is_array($data))
			{
				foreach($data as $m)
				{
					$m['Code'] = str_replace(' ', '-', strtolower($m['Title']));
					$sql = "UPDATE `hc_am_models` SET `Code` = '".$m['Code']."' WHERE `hc_am_models`.`Id` = ".$m['Id'].";";
					$q = $db->query($sql);
					$out .= '<br />'.$sql;
				}
			}
			
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{

			$sql = "ALTER TABLE `hc_sitemap_static_html` ADD `FormId` INT NOT NULL DEFAULT '0' AFTER `html`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			
			$sql = "ALTER TABLE `hc_fm_forms` ADD `MailTo` VARCHAR(250) NOT NULL DEFAULT '' AFTER `action`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
	
			$out .= self::insertWord('form', 'form', 'formular', 'responsskjema');
			
			$katana->setVersion($v);
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_product_vars` ADD `active` TINYINT(1) NOT NULL DEFAULT '1' ;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
			$v++;
		}
		$v++;
		
		if($katana->getVersion() < $v)
		{
			$out .= self::insertWord('ExcludedVAT', 'Excluded VAT.', 'bez PDV.', 'ekskl. mva.');
			$katana->setVersion($v);
		}
		$v++;
		
		
		$sql = 'SELECT Brands.* FROM `hc_am_brands` AS Brands';
		$result = $db->query($sql);
		$data = $db->fetch($sql, 0);
		$out .= '<br />'.$sql;
		
		if(is_array($data))
		{
			foreach($data as $m)
			{
				$m['Code'] = strtolower($m['Code']);
				$sql = "UPDATE `hc_am_brands` SET `Image` = '".$m['Code'].".jpg',  `Code` = '".$m['Code']."' WHERE `hc_am_brands`.`id` = ".$m['id'].";";
				$q = $db->query($sql);
				$out .= '<br />'.$sql;
			}
		}
		/*
		if($katana->getVersion() < $v)
		{
			$sql = "ALTER TABLE `hc_shop_orders` ADD `DoubleConfirmed` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `confirmed`;";
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
			$katana->setVersion($v);
			$v++;
		}
		*/
		$out .= '<br />Upgraded To:'.$katana->getVersion();
		self::saveVersion();
		return $out;
	}
	
	public function saveVersion()
	{
		global $katana;
		global $db;
		$sql = 'UPDATE '.DB_PERFIX.'sites SET Version='.$katana->getVersion().' WHERE id='.$katana->getId().' LIMIT 1;';
		$result = $db->query($sql);
	}
	
	public function insertWord($key, $en, $bs, $no, $KatanaCore=0)
	{
		$out = '<br />insertWord Parameters missing key:'.$key;
		if(($key != '') && ($en != '') && ($bs != '') && ($no != ''))
		{
			global $txt;
			global $db;
			$words = $txt->getWords();
			if(isset($words[$key]))
			{
				$out  = '<br />Updating Word width key:'.$key;
				$sql  = 'UPDATE '.DB_PERFIX.'`words` SET ';
				$sql .= '`katana_core`='.$KatanaCore.', ';
				$sql .= '`en`="'.self::formatText($en).'", ';
				$sql .= '`bs`="'.self::formatText($bs).'", ';
				$sql .= '`no`="'.self::formatText($no).'", ';
				$sql .= '`image`="'.self::formatText(self::getImage()).'", ';
				$sql .= '`active`='.self::getActive().' ';
				$sql .= ' WHERE value="'.$key.'" LIMIT 1;';
			}
			else
			{
				$out  = '<br />Adding Word width key:'.$key;
				$sql  = "INSERT INTO `hc_words` (`value`, `frontend`, `backend`, `modcom_set`, `katana_core`, `en`, `bs`, `no`) VALUES ";
				$sql .= "('".$key."', '1', '1', '0', '".$KatanaCore."', '".$en."', '".$bs."', '".$no."');";
			}
			$result = $db->query($sql);
			$out .= '<br />'.$sql;
		}
		return $out;
	}
}
?>